package com.demo.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author：不想早起
 * @Package：com.demo.config
 * @Project：ESDemo
 * @name：ElasticSearchClientConfig
 * @Date：2024/2/26 20:49
 * @Filename：ElasticSearchClientConfig
 */
@Configuration
public class ElasticSearchClientConfig {
    /*
     * 将创建ES链接的代码，注入到Spring的容器当中
     * */
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("127.0.0.1", 9200, "http")
                )
        );
        return client;
    }

}
